package com.jbp.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jbp.dao.UserSendGiftLogDao;
import com.jbp.model.UserSendGiftLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.jbp.utils.PageUtils;
import com.jbp.utils.Query;

import java.math.BigDecimal;
import java.util.Map;

@Service
public class UserSendGiftLogService extends ServiceImpl<UserSendGiftLogDao, UserSendGiftLog> implements IService<UserSendGiftLog> {
    @Autowired
    private TecentMsgService tecentMsgService;

    public PageUtils queryPage(Map<String, Object> params) {
        QueryWrapper<UserSendGiftLog> queryWrapper = new QueryWrapper<>();
        if (params.get("fromUserId") != null) {
            queryWrapper.like("from_user_id",params.get("fromUserId"));
        }
        if (params.get("toUserId") != null) {
            queryWrapper.like("to_user_id",params.get("toUserId"));
        }
        if (params.get("type") != null) {
            queryWrapper.like("type",params.get("type"));
        }
        if (params.get("roomId") != null) {
            queryWrapper.like("room_id",params.get("roomId"));
        }
        queryWrapper.orderByDesc("id");
        IPage<UserSendGiftLog> page = this.page(
            new Query<UserSendGiftLog>().getPage(params), queryWrapper
        );
        return new PageUtils(page);
    }

    /**送礼消息*/
    public void sendGiftMsg(Integer fromUserId, Integer toUserId, String log){
        boolean b =  tecentMsgService.sendMsg(fromUserId.toString(), toUserId.toString(), log, "sendGift");
    }
}